package com.example.disk.obs;

import java.io.*;

/**
 * TODO
 *
 * @author lpc
 * @version 1.0.0
 * @since 2020-07-16 15:22
 */
public interface OBSAgent {

    /**
     * @description: 创建文件夹
     * @param: username
     * @param: parentPath
     * @param: dirname
     * @return: boolean
     * @author: Xiong Mian
     * @date: 2020/7/19
     */
    boolean makeDir(String username, String parentPath, String dirname);

    boolean makeRootDir(String username);

    boolean storeFile(String username, String aimPath, FileOutputStream fos);

    /**
     * @description: 上传文件
     * @param: username
     * @param: aimPath 文件路径，不包含文件名
     * @param: filename 文件名
     * @param: file
     * @return: boolean
     * @author: Xiong Mian
     * @date: 2020/7/18
     */
    boolean storeFile(String username, String aimPath, String filename, InputStream is) throws FileNotFoundException;

    /**
     * @description: 下载文件
     * @param: username
     * @param: path
     * @param: filename
     * @return: java.io.File
     * @author: Xiong Mian
     * @date: 2020/7/18
     */
    File getFile(String username, String path, String filename) throws IOException;

    /**
     * 从obs
     * @param username
     * @param path
     * @param filename
     * @return
     */
    InputStream getInputStream(String username, String path, String filename) throws IOException;


    /**
     * @description: 移动文件
     * @param: username
     * @param: sourcePath
     * @param: aimPath
     * @param: filename
     * @return: boolean
     * @author: Xiong Mian
     * @date: 2020/7/18
     */
    boolean moveFile(String username, String sourcePath, String aimPath, String filename) throws IOException;

    boolean moveDir(String username, String sourcePath, String aimPath, String filename) throws IOException;
    /**
     * @description: 删除文件
     * @param: username
     * @param: path
     * @param: filename
     * @return: boolean
     * @author: Xiong Mian
     * @date: 2020/7/19
     */
    boolean deleteFile(String username, String path, String filename);

    /**
     * @description: 重命名文件
     * @param: username
     * @param: path
     * @param: oldFileName
     * @param: newFileName
     * @return: boolean
     * @author: Xiong Mian
     * @date: 2020/7/19
     */
    boolean renameFile(String username, String path, String oldFileName, String newFileName) throws IOException;

    /**
     * @description: 获取文件的预览url
     * @param: username
     * @param: path
     * @param: filename
     * @return: java.lang.String
     * @author: Xiong Mian
     * @date: 2020/7/18
     */
    String getUrl(String username, String path, String filename) throws IOException;


    InputStream downloadFile(String username, String path, String filename);


}
